package org.srtc.infopub.application.dacc.imp;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.srtc.infopub.application.dacc.MonitorInfoService;
import org.srtc.infopub.datacenter.storage.TestCache;
import org.srtc.infopub.tools.ProtocolPaser;
import org.srtc.infopub.tools.QueryResults;



public class MonitorInfoServiceImp implements MonitorInfoService {

//	public BaseData monitInfoFind(String nodeName, String typeName) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//	public List<BaseData> monitInfoFind(List nodeNames, String TypeName) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//	public List<BaseData> monitInfoFind(String nodeName, List TypeNames) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//	public Map<String, List<BaseData>> monitInfoFind(List nodeNames,
//			List TypeNames) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//	public BaseData monitInfoFind(String nodeName, String typeName,
//			Date beginDate, Date endDate) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//	public List<BaseData> monitInfoFind(List nodeNames, String TypeName,
//			Date beginDate, Date endDate) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//	public List<BaseData> monitInfoFind(String nodeName, List TypeNames,
//			Date beginDate, Date endDate) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//	public Map<String, List<BaseData>> monitInfoFind(List nodeNames,
//			List TypeNames, Date beginDate, Date endDate) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//	public Catalog monitTypeFind(String nodeName) {
//		// TODO Auto-generated method stub
//		return null;
//	}

	@Override
	public String nodeGet() {
		// TODO Auto-generated method stub
		return "node1,node2,node3";
	}

	@Override
	public String nodeInfo(String nodeId) {
		// TODO Auto-generated method stub
		return "gas,water,press";
	}

	
	
	

//+++++++++++++++++++++++++++++++++++++取消此处注释内容即可	
	@Override
	public String queryInfo(String query) {

		TestCache tc = TestCache.instance();
		
		ArrayList<String> ques = new ArrayList<String>();
		ques.add(query);
		
		ProtocolPaser pp = new ProtocolPaser();
		String qStr = pp.getQueryField(query, "exceptProtocol");
		
		ArrayList<String> q = new ArrayList<String>();
		q.add(qStr);
		
		HashMap<String, Object> m = tc.processQuery(ques);
		QueryResults queryResults = tc.getQueryResults(q, m);
//		System.out.println(queryResults);
		StringBuffer result = new StringBuffer();
		if (queryResults == null) {
			return result.toString();
		}
		Entry<String, Object> tem = queryResults.moveNext();

		while(tem != null)
		{
			result.append(tem.getKey() + ":" + tem.getValue().toString()
					+ ",");
			tem = queryResults.moveNext();
		}
		
//		System.out.println(result + "////////////");
		return result.toString();
//		return "001.001.001:123,001.001.002:123,001.001.003:234,001.001.004:897,001.001.005:97,001.001.006:ttf," +
//		"002.001.001:123,002.001.002:123,002.001.003:234,002.001.004:897,002.001.005:97,002.001.006:ttf";
	}

}
